﻿namespace EyeOpen.DataEntry.Data
{
	using System.Configuration;
	using System.Data.Entity;
	using System.Data.Entity.ModelConfiguration.Conventions;

	using EyeOpen.Data;
	using EyeOpen.DataEntry.Domain;

	internal class ShopUnitOfWork : 
		EntityFrameworkUnitOfWork, 
		IShopUnitOfWork, 
		IShopDb
	{
		public ShopUnitOfWork(string connectionName)
			: base(connectionName)
		{
		}

		public ShopUnitOfWork(ConnectionStringSettings connectionSettings)
			: base(connectionSettings)
		{
		}

		public ShopUnitOfWork(string providerName, string connectionString)
			: base(providerName, connectionString)
		{
		}

		public IRepository<Customer> CustomerRepository
		{
			get
			{
				return Repository<Customer>();
			}
		}

		public bool Exists()
		{
			return Database.Exists();
		}

		public void Create()
		{
			Database.Create();
		}

		protected override void OnModelCreating(DbModelBuilder modelBuilder)
		{
			modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
			modelBuilder.Entity<Customer>();
		}
	}
}